#include "../begonia.h"
#include "returnbullet.h"
#include "tempbullet.h"
#include "../base/scene.h"

returningbullet::returningbullet(double tx,double ty,double tr,double tvx,double tvy,double tp,bullet *h):bullet(tx,ty,tr,tvx,tvy,h)
    {
        p=tp;
        t0=t;
    }
void returningbullet::clone(bullet *h)
    {
        bullet *a=new bullet(x,y,r,vx,vy,h);
        a->c_r=c_r;
        a->c_g=c_g;
        a->c_b=c_b;
    }
void returningbullet::remove()
{
    tempbullet *a=new tempbullet(x,y,r,-vx,-vy,t-t0,&f.head);
    a->c_r=1.0;
    delete this;
}
bool returningbullet::move()
    {
        x+=vx*(t-tlast);
        y+=vy*(t-tlast);
        if((vx>0.0?x-r>scw:x+r<0.0)||(vy>0.0?y-r>sch:y+r<0.0)||rand()%32768<32768.0*p) {remove();return false;}
        return true;
    }
